package com.example.bgmachine.bgmachine.goods;

import android.content.Context;
import android.graphics.Typeface;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.bgmachine.bgmachine.R;

import java.util.ArrayList;

public class HomepageListLeftMenuAdapter extends BaseAdapter {
    private Context context;
    private ArrayList<HomepageLeftMenuItemData> list = new ArrayList<HomepageLeftMenuItemData>();

    public HomepageListLeftMenuAdapter(Context context, ArrayList<HomepageLeftMenuItemData> list) {
        this.context = context;
        this.list = list;
    }
    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return list.size();
    }
    @Override
    public HomepageLeftMenuItemData getItem(int position) {
        // TODO Auto-generated method stub
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view=View.inflate(context, R.layout.homepage_list_left_menu_adapter, null);
        TextView home_list_left_menu_titles=(TextView)view.findViewById(R.id.homepage_grid_right_menu_titles);
        View home_list_left_menu_image=view.findViewById(R.id.homepage_grid_right_menu_image);
        home_list_left_menu_titles.setText(list.get(position).getMenuNames());
        if(position==LeftSelectindex.getLeftSelectindex().mLeftSelectIndex){
            home_list_left_menu_image.setVisibility(ImageView.VISIBLE);
            home_list_left_menu_titles.setTextColor(context.getResources().getColor( R.color.homepage_list_left_menu_title_select) );
            view.setBackgroundResource(R.color.homepage_list_left_menu_ground_select);
            home_list_left_menu_titles.setTypeface(null, Typeface.BOLD);
        }else{

            home_list_left_menu_image.setVisibility(ImageView.GONE);
            home_list_left_menu_titles.setTextColor(context.getResources().getColor( R.color.homepage_list_left_menu_title_nomal) );

            view.setBackgroundResource(R.color.homepage_list_left_menu_ground_nomal);
            home_list_left_menu_titles.setTypeface(null, Typeface.NORMAL);
        }
        return view;
    }
}
